<template>
  <div>
    <h2>我是加载列表的子组件</h2>
    <ul>
        <li v-for="item in tableData" :key="item.t_plant_pk">{{item.plant_name}}</li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
import ajax from "@/util/request";
import {defineProps,watch,reactive} from "vue";

const props = defineProps({
    modelValue: {
        type: String
    }
});

const tableData = reactive<any>([]);

watch(() => props.modelValue,newVal => {
    console.log("有新值传来：",newVal);
    ajax("/plant/queryList",{t_cat_pk:newVal}).then(({data}) => {
        if (data.status > 0) {
            tableData.length = 0;
            tableData.push(...data.result_data);
        }
    })
})

</script>

<style>

</style>